import BoxRotateScript from './BoxRotateScript';
import CameraControllerScript from './CameraControllerScript';
export default class BoxScene extends Laya.Scene {
    constructor() {
        super();
        //加载场景文件
        //this.loadScene("main.scene");

        //添加3D场景
        var scene = Laya.stage.addChild(new Laya.Scene3D());

        //添加照相机
        var camera = (scene.addChild(new Laya.Camera(0, 0.1, 100)));
        camera.transform.translate(new Laya.Vector3(0, 0, 5));
        camera.name='Main Camera';
        

        //添加方向光
        var directionLight = scene.addChild(new Laya.DirectionLight());
        directionLight.color = new Laya.Vector3(0.6, 0.6, 0.6);
        directionLight.transform.worldMatrix.setForward(new Laya.Vector3(1, -1, 0));

        //添加自定义模型
        var box = scene.addChild(new Laya.MeshSprite3D(Laya.PrimitiveMesh.createBox(1, 1, 1)));
        
        box.transform.translate(new Laya.Vector3(0, 0, -5));
        //box.transform.rotate(new Laya.Vector3(0, 45, 0), false, false);
        var material = new Laya.BlinnPhongMaterial();
		Laya.Texture2D.load("res/layabox.png", Laya.Handler.create(null, function(tex) {
				material.albedoTexture = tex;
		}));
        box.meshRenderer.material = material;
        box.addComponent(CameraControllerScript);
       
    }

}